//
//  ZH_MineSignTableViewCell.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/10/22.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_MineSignTableViewCell.h"
@interface ZH_MineSignTableViewCell()<UITextViewDelegate>
@property (nonatomic,weak)UILabel *signLabel;
///备注
@property (nonatomic,weak)UITextView *inputTextView;
///备注的说明
@property (nonatomic,weak)UILabel *instructionsLabel;
@end
@implementation ZH_MineSignTableViewCell

///创建
+(instancetype)cellWithTableView:(UITableView*)tableView
{
    static NSString *ID = @"ZH_MineSignTableViewCell";
    ZH_MineSignTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if(cell == nil){
        cell = [[ZH_MineSignTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}
///初始化
-(void)initDefault
{
    [self unShowClickEffect];
//    self.bottomShortLineImage.hidden = NO;
}
- (void)loadSubviewConstraints{
    [self.signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(24));
        make.left.equalTo(self.contentView).offset(FITSCALE(22));
    }];
    [self.inputTextView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.signLabel.mas_bottom).offset(FITSCALE(12));
        make.left.equalTo(self.contentView).offset(FITSCALE(11));
        make.right.equalTo(self.contentView).offset(FITSCALE(-11));
        make.height.mas_equalTo(FITSCALE(71));
        make.bottom.equalTo(self.contentView);
    }];
    [self.instructionsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.inputTextView).offset(FITHEIGHT(7));
        make.left.equalTo(self.inputTextView).offset(FITWITH(10));
    }];
}
///输入框 回调 方法
- (void)textViewDidEndEditing:(UITextView *)textView{
    
//    if (self.onInputTextViewBlock) {
//        self.onInputTextViewBlock(textView.text);
//    }
}
- (void)textViewDidChange:(UITextView *)textView{
    if (textView.text.length == 0) {
        _instructionsLabel.hidden = NO;
    }
    else {
        _instructionsLabel.hidden = YES;
    }
}
#pragma mark - getter,setter
- (UILabel *)signLabel{
    if (!_signLabel) {
        UILabel *label = [UILabel createLabelWithText:@"签名" font:kFontSize_28];
        [self.contentView addSubview:_signLabel = label];
    }
    return _signLabel;
}
///输入内容
- (UITextView *)inputTextView
{
    if(!_inputTextView){
        UITextView *textView= [UITextView createTextViewWithDelegateTarget:self];
        textView.font = kFontSize_26;
        textView.layer.borderWidth = 1.0f;
        textView.backgroundColor = kCommonBackgroudColor;
        textView.layer.borderColor = [UIColor colorWithHexString:@"#EEEEEE"].CGColor;
        [self.contentView addSubview:_inputTextView = textView];
    }
    return _inputTextView;
}
- (UILabel *)instructionsLabel{
    if (!_instructionsLabel) {
        UILabel *label = [UILabel createLabelWithText:@"请输入个人签名" font:kFontSize_26];
        label.textColor = [UIColor colorWithHexString:@"#969696"];
        [self.contentView addSubview:_instructionsLabel = label];
    }
    return _instructionsLabel;
}
@end
